package com.sgx.learning.luban.io.bio;

import java.io.IOException;
import java.net.Socket;

public class SocketClient {

    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("localhost",9000);

        socket.getOutputStream().write("hello server".getBytes());
        socket.getOutputStream().flush();
        System.out.println("向服务器端发送数据结束");
        byte[] b = new byte[1024];
        int read = socket.getInputStream().read(b);
        System.out.println("接受服务器的数据:" + new String(b,0,read));
        socket.close();
    }
}
